<html>
<head>
    <meta http-equiv="content-type" content="text/html;charset=utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <script src="__STATIC__/js/jquery-1.11.3.min.js"></script>
    <title>微信支付</title>
</head>
<div style="width: 1000px; margin: auto;">
<div style="width: 500px;height: 500px;text-align:center;margin: auto;">
    <img alt="模式二扫码支付" src="{:url('WeChat/or_code',array('data'=>base64_encode($url)))}" style="width:200px;height:200px;margin-top: 100px;"/>
    <span style="display: block;">微信扫码支付</span>
</div>
</div>
<input type="hidden" id="order" value="{$order}">
<input type="hidden" id="action" value="{$return_url}">
</body>
<script>
    $(document).ready(function () {
        var action = $('#action').val();
        if (action==1) {
            setInterval("ajaxstatus()", 5000);
        }else {
            setInterval("ajaxrechage()", 5000);
        }

    });

    function ajaxstatus() {
        var order_num = $("#order").val();
        if ( order_num!= 0) {
            $.ajax({
                url: "{:url('shop/WeChat/check_order')}",
                type: "GET",
                dataType:"json",
                data: {'order':order_num},
                success: function (data) {
                    //订单状态为1表示支付成功
                    if (data.code==200) {

                        //页面跳转
                        window.location.href = "{:url('shop/information/index')}?select=information";
                    }
                },
                error: function () {
                    alert("请求订单状态出错");
                }
            });
        }
    }


    function ajaxrechage() {
        var order_num = $("#order").val();
        if ( order_num!= 0) {
            $.ajax({
                url: "{:url('shop/WeChat/check_charge')}",
                type: "GET",
                dataType:"json",
                data: {'order':order_num},
                success: function (data) {
                    //订单状态为1表示支付成功
                    if (data.code==200) {
                        //页面跳转
                        window.location.href = "{:url('shop/member_wallet/index')}";
                    }
                },
                error: function () {
                    alert("请求订单状态出错");
                }
            });
        }
    }
</script>
</html>